<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Identi Engine Documentation - Identities</title>

<link rel="stylesheet" href="../css/site.css" type="text/css" media="all" />
<link rel="stylesheet" href="../css/documentation.css" type="text/css" media="all" />
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
<link rel="shortcut icon" href="../images/logo16.png"/>

<link type="application/rss+xml" rel="alternate" title="Ident Engine (RSS)" href="http://identengine.com/Blog/syndication.axd?format=rss" />
<link type="application/atom+xml" rel="alternate" title="Ident Engine (ATOM)" href="http://identengine.com/Blog/syndication.axd?format=atom" />

</head>

<body>
	<div class="header">
		<div class="centered">
			<a href="http://identengine.com/"><h1><span>Ident Engine</span></h1></a>
			<h2 id="strapline"><span>A JavaScript library that retrieves and aggregates profiles from across the web</span> </h2>
		</div>
	</div>

	<div class="content">
		<div class="centered">
		<div class="floatclear" style="clear:both">
			<ul class="menu">
				<li><a href="../index.htm" class="firstItem">home</a></li>
				<li><a href="index.htm">documentation</a></li>
				<li><a href="../opentables/index.htm">api</a></li>
				<li><a href="http://identengine.com/blog/">blog</a></li>
				<li><a href="../about/index.htm" class="lastItem">about</a></li>
			</ul>
		</div>	

	
		<h1>Documentation - Identities</h1>
		
		
		<p class="title-expansion">How to search across people&#39;s identities and build lists of 
		their online accounts.</p>
		
		<p>
		Given a profile URL of an individual, the Identi Engine can collect a 
		list of social media site 
		accounts related to that person. It stores this information in a 
		collection called ident.identities. See demo:
		<a href="../identity-discovery.htm">Identity discovery</a>
		</p>
		
		<h2>1. Creating a search</h2>
		
<pre>var doc = jQuery(document);

doc.ready(function () {
    ident.useInwardEdges = true;
    ident.iconPath = "identi/icons/";
    ident.addPrimaryURL = true;

    doc.bind('ident:update', renderProfile);

    ident.search(&#39;http://twitter.com/glennjones&#39;);
});</pre>
		<p> 
		The code snippet above is using jQuery to create a function which 
		executes as soon as the HTML document is loaded. Within the function 
		call we set a number of search properties. 
		</p>
		
		
		<h3>Properties</h3>
		    <dl>
				<dt>useInwardEdges</dt>
                <dd>The useInwardEdges property controls how the identities are found. If it is 
		set to true it will return a larger sets of results, but there is a 
		greater chance that Identi Engine will return the wrong information about an 
		individual. There will be less of a chance of error if the property is 
		set to false. By default this 
		property is set&nbsp; to true.</dd>
		
                 <dt>iconPath</dt>
                 <dd>The iconPath property is a string which is added in front of the 
		icon file name. It allows you to modify the iconUrl path information in 
		the results.</dd>

                 <dt>addPrimaryURL</dt>
                 <dd>The addPrimaryURL property determines whether the result set 
		should start with the URL most commonly associated with the individual. This 
		is often a blog URL. By default this property is set to true.</dd>
                            
   
            </dl>
		
		<h3>Binding the rendering function</h3>
			
		<p>The Identi Engine will update the identities collection a number of 
		times during a single search. To capture the updates we need to bind our 
		own rendering function to the events fired by the library. 
		This can be done easily with jQuery for example:</p>
		
		<pre> doc.bind(&#39;ident:update&#39;, renderProfile);</pre>
		
		<p>The code above will cause the function called renderProfile to be fired 
		every time the Identi Engine updates it&#39;s identities collection. </p>
		
		
		
		<h2>2. Rendering results</h2>
		
<pre>
function renderProfile(e){
  
     jQuery('#identities').html('');
    
     if(ident.identities.length &gt; 0){
         var ul = jQuery('&lt;ul class="profile-list"&gt;&lt;/ul&gt;').appendTo('#identities'); 
         for (var x = 0; x &lt; ident.identities.length; x++) {
            if(ident.identities[x].name != '')
                jQuery('&lt;li&gt;
                    &lt;a href="' + ident.identities[x].profileUrl  + '"&gt;
                    &lt;img width="16" class="icon" src="' + ident.identities[x].iconUrl + '" /&gt;' 
                    + ident.identities[x].name + '&lt;/a&gt; &lt;span class="username"&gt;(' + 
                    ident.identities[x].username + ')&lt;/span&gt;
                    &lt;/li&gt;').appendTo(ul);   
            else
                jQuery('&lt;li&gt;
                &lt;a href="' + ident.identities[x].profileUrl  + '"&gt;
                &lt;img width="16" class="icon" src="' + ident.identities[x].iconUrl +  '" /&gt;'
                 + ident.identities[x].domain + '&lt;/a&gt;&lt;/li&gt;').appendTo(ul); 
         }
     }  
}</pre>

		<p>The renderProfile function uses jQuery to create a list of accounts 
		in a HTML element with the ID identities. It simply loops through the 
		collection creating the &lt;li&gt; list item from the properties listed above. 
		It checks to see if the account has a name property to decide how 
		it will render the list item.</p>
		<p>Please read the page <a href="identities-structure.htm">
		ident.identities data structure</a> 
		for a complete overview of the data returned by this search </p>
		<h2>The files that need to be included in the page</h2>
		<p>There are two files you must include 
		in your HTML for the Identi Engine to create 
		the identities collection. </p>
		<pre id="line1"><span class="attribute-value">jquery-1.3.2.min.js</span>
<span class="attribute-value">identi-0.1.js</span></pre>
		<p>You can then enhance your results by adding two more files. Including 
		the&nbsp; <span class="attribute-value">identi-profile-0.1.js </span>file will 
		automatically upgrade the search feature without having to add any extra 
		code. With this file present the search feature will parse each profile 
		page it finds for extra information. Although it may return a more 
		complete set of results it is slower due to the additional API calls 
		made. The <span class="attribute-value">identi-profile-0.1.js file needs one of 
		the two parsers. In the example below we are using the YQL parser.</span></p>
		<pre id="line26"><span class="attribute-value">jquery-1.3.2.min.js
identi-0.1.js
identi-profile-0.1.js
identi-yql-parser-0.1.js</span></pre>
		<p>Alternatively, you can swap the parser to UfXtract which in some 
		cases will return more results. The UfXtract parser should only be 
		used for low traffic situations.</p>
		<pre><span class="attribute-value">jquery-1.3.2.min.js
identi-0.1.js
identi-profile-0.1.js
identi-ufxtract-parser-0.1.js</span></pre>
		<p>&nbsp;</p>
		
		
		
</div>
		</div>
		
		
   <div class="footer">
		<div class="centered">
			<p class="cc-license">
				<a rel="license" href="http://creativecommons.org/licenses/by/2.0/uk/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/2.0/uk/80x15.png" /></a><br /><span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" property="dc:title" rel="dc:type">Identi Engine Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.glennjones.net/" property="cc:attributionName" rel="cc:attributionURL">Glenn Jones</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/2.0/uk/">Creative Commons Attribution 2.0 UK: England &amp; Wales License</a>.<br />Based on a work at <a xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://identengine.com/" rel="dc:source">identengine.com</a>.
			</p>
			<div class="copyright">© Copyright Glenn Jones 2009. All Rights Reserved.</div>
		</div>
	</div>

	<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3021774-6");
pageTracker._trackPageview();
} catch(err) {}</script>

</body>
</html>
